package com.maegul.dao.implementations;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.maegul.dao.SessionDAO;
import com.maegul.dao.entities.MediaItem;
import com.maegul.dao.entities.UserSession;

@Repository
public class SessionStore implements SessionDAO {

	@PersistenceContext(unitName = "maegul")
	protected EntityManager em;

	@Override
	@Transactional
	public UserSession getSession(String username) {
		return em.find(UserSession.class, username);
	}

	@Override
	@Transactional
	public void saveSession(UserSession uSession) {
		em.persist(uSession);
	}

	@Override
	@Transactional
	public boolean storeCart(String username, List<MediaItem> cart) {
		// TODO Probablmente no vaya aca...
		return false;
	}

}
